package eerbaar.v2.pattern.client;

import eerbaar.message.lib.CollisionMsg;
import eerbaar.message.lib.LevelChangeMsg;
import eerbaar.message.lib.NotifyPetAtEdgeMsg;
import eerbaar.shared.message.MsgHelper;
import eerbaar.v2.app.core.IApp;
import eerbaar.v2.app.extension.IExtension;
import eerbaar.v2.app.menu.IMenuProvider;
import eerbaar.v2.menu.PetMenuProvider;
import eerbaar.v2.pattern.client.internal.readers.CollisionMsgReader;
import eerbaar.v2.pattern.client.internal.readers.LevelChangeReader;
import eerbaar.v2.pattern.client.internal.readers.PetAtEdgeMsgReader;
import eerbaar.v2.pattern.client.internal.teach.TeachMenu;
import eerbaar.v2.pattern.client.internal.ui.ProgramPanel;

public class PatternExtension implements IExtension {

    @Override
    public void install(IApp app) {

        app.addGamePanel(new ProgramPanel(app.getMainWindow().getRightPanel()));

        IMenuProvider provider = app.getMenuService().get(
                PetMenuProvider.PET_MENU);
        TeachMenu item = new TeachMenu();

        {
            CollisionMsgReader reader = new CollisionMsgReader(
                    item.getCommand());
            MsgHelper.registerReader(CollisionMsg.class, reader);
        }
        {
            PetAtEdgeMsgReader reader = new PetAtEdgeMsgReader(
                    item.getCommand());
            MsgHelper.registerReader(NotifyPetAtEdgeMsg.class, reader);
        }
        {
            LevelChangeReader reader = new LevelChangeReader();
            MsgHelper.registerReader(LevelChangeMsg.class, reader);
        }

        provider.addMenuItem(item);
    }

}
